import { defineComponent, ref, computed } from "vue";
import style from "./index.module.less";
import PageTitle from "@/components/PageTitle";
import Form from "@/components/Form";
import { IFormItem } from "@/components/Form/types";
import ButtonView from "@/components/ButtonView";
import CardView from "@/components/CardView";
import { useRequest } from "./request";
import FormGroup from "@/components/FormGroup";
import { FormGroupPropsData } from "@/components/FormGroup/types";
import FarmProductDetail from "@/pages/farmProductDetail";
export default defineComponent({
  name: "",
  setup() {
    const { farmInfo, confirm } = useRequest();
    const data = computed<FormGroupPropsData[]>(() => [
      {
        data: [
          {
            key: "productList",
            label: "所用农资",
            type: "uploadPopup",
            view: FarmProductDetail,
          },
        ],
      },
    ]);
    const render1 = () => {
      return (
        <div class={"p-[10px]"}>
          <CardView>
            <FormGroup data={data.value} v-model={farmInfo.value} />
          </CardView>
          <ButtonView
            block
            type="primary"
            onClick={() => confirm(farmInfo.value)}
            class="!mt-[20px] !h-[40px]"
          >
            确定
          </ButtonView>
        </div>
      );
    };
    return () => {
      return <PageTitle title="我的农资">{render1()}</PageTitle>;
    };
  },
});
